# Copyright 2010-2024 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package(default_visibility = ["//ortools:__subpackages__"])

cc_library(
    name = "ids_validator",
    srcs = ["ids_validator.cc"],
    hdrs = ["ids_validator.h"],
    deps = [
        "//ortools/base:status_macros",
        "//ortools/math_opt/core:model_summary",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "scalar_validator",
    srcs = ["scalar_validator.cc"],
    hdrs = ["scalar_validator.h"],
    deps = [
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "sparse_matrix_validator",
    srcs = ["sparse_matrix_validator.cc"],
    hdrs = ["sparse_matrix_validator.h"],
    deps = [
        ":ids_validator",
        "//ortools/base:status_macros",
        "//ortools/math_opt:model_cc_proto",
        "//ortools/math_opt:sparse_containers_cc_proto",
        "//ortools/math_opt/core:model_summary",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "sparse_vector_validator",
    hdrs = ["sparse_vector_validator.h"],
    deps = [
        ":ids_validator",
        ":scalar_validator",
        "//ortools/base:status_macros",
        "//ortools/math_opt/core:sparse_vector_view",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "model_validator",
    srcs = ["model_validator.cc"],
    hdrs = ["model_validator.h"],
    deps = [
        ":ids_validator",
        ":scalar_validator",
        ":sparse_matrix_validator",
        ":sparse_vector_validator",
        "//ortools/base:status_macros",
        "//ortools/math_opt:model_cc_proto",
        "//ortools/math_opt:model_update_cc_proto",
        "//ortools/math_opt:sparse_containers_cc_proto",
        "//ortools/math_opt/constraints/indicator:validator",
        "//ortools/math_opt/constraints/quadratic:validator",
        "//ortools/math_opt/constraints/second_order_cone:validator",
        "//ortools/math_opt/constraints/sos:validator",
        "//ortools/math_opt/core:model_summary",
        "//ortools/math_opt/core:sparse_vector_view",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
    ],
)

cc_library(
    name = "solve_stats_validator",
    srcs = ["solve_stats_validator.cc"],
    hdrs = ["solve_stats_validator.h"],
    deps = [
        "//ortools/base:protoutil",
        "//ortools/math_opt:result_cc_proto",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
    ],
)

cc_library(
    name = "result_validator",
    srcs = ["result_validator.cc"],
    hdrs = ["result_validator.h"],
    deps = [
        ":solution_validator",
        ":solve_stats_validator",
        ":termination_validator",
        "//ortools/base:status_macros",
        "//ortools/math_opt:model_parameters_cc_proto",
        "//ortools/math_opt:result_cc_proto",
        "//ortools/math_opt:solution_cc_proto",
        "//ortools/math_opt/core:math_opt_proto_utils",
        "//ortools/math_opt/core:model_summary",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/status",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_library(
    name = "solution_validator",
    srcs = ["solution_validator.cc"],
    hdrs = ["solution_validator.h"],
    deps = [
        ":ids_validator",
        ":scalar_validator",
        ":sparse_vector_validator",
        "//ortools/base:status_macros",
        "//ortools/math_opt:model_parameters_cc_proto",
        "//ortools/math_opt:solution_cc_proto",
        "//ortools/math_opt:sparse_containers_cc_proto",
        "//ortools/math_opt/core:math_opt_proto_utils",
        "//ortools/math_opt/core:model_summary",
        "//ortools/math_opt/core:sparse_vector_view",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "solve_parameters_validator",
    srcs = ["solve_parameters_validator.cc"],
    hdrs = ["solve_parameters_validator.h"],
    deps = [
        "//ortools/base:protoutil",
        "//ortools/base:status_macros",
        "//ortools/math_opt:parameters_cc_proto",
        "//ortools/util:status_macros",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
    ],
)

cc_library(
    name = "callback_validator",
    srcs = ["callback_validator.cc"],
    hdrs = ["callback_validator.h"],
    deps = [
        ":ids_validator",
        ":model_parameters_validator",
        ":scalar_validator",
        ":solution_validator",
        ":sparse_vector_validator",
        "//ortools/base:logging",
        "//ortools/base:status_macros",
        "//ortools/math_opt:callback_cc_proto",
        "//ortools/math_opt:solution_cc_proto",
        "//ortools/math_opt:sparse_containers_cc_proto",
        "//ortools/math_opt/core:math_opt_proto_utils",
        "//ortools/math_opt/core:model_summary",
        "//ortools/math_opt/core:sparse_vector_view",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_library(
    name = "model_parameters_validator",
    srcs = ["model_parameters_validator.cc"],
    hdrs = ["model_parameters_validator.h"],
    deps = [
        ":ids_validator",
        ":solution_validator",
        ":sparse_vector_validator",
        "//ortools/base:status_macros",
        "//ortools/math_opt:model_parameters_cc_proto",
        "//ortools/math_opt:sparse_containers_cc_proto",
        "//ortools/math_opt/core:model_summary",
        "//ortools/math_opt/core:sparse_vector_view",
        "@com_google_absl//absl/status",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_library(
    name = "linear_expression_validator",
    srcs = ["linear_expression_validator.cc"],
    hdrs = ["linear_expression_validator.h"],
    deps = [
        ":scalar_validator",
        ":sparse_vector_validator",
        "//ortools/base:status_macros",
        "//ortools/math_opt:sparse_containers_cc_proto",
        "//ortools/math_opt/core:model_summary",
        "//ortools/math_opt/core:sparse_vector_view",
        "@com_google_absl//absl/status",
    ],
)

cc_library(
    name = "infeasible_subsystem_validator",
    srcs = ["infeasible_subsystem_validator.cc"],
    hdrs = ["infeasible_subsystem_validator.h"],
    deps = [
        ":bounds_and_status_validator",
        ":ids_validator",
        "//ortools/base:status_macros",
        "//ortools/math_opt:infeasible_subsystem_cc_proto",
        "//ortools/math_opt:result_cc_proto",
        "//ortools/math_opt/core:model_summary",
        "@com_google_absl//absl/status",
    ],
)

cc_library(
    name = "bounds_and_status_validator",
    srcs = ["bounds_and_status_validator.cc"],
    hdrs = ["bounds_and_status_validator.h"],
    deps = [
        ":scalar_validator",
        "//ortools/base:status_macros",
        "//ortools/math_opt:result_cc_proto",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "termination_validator",
    srcs = ["termination_validator.cc"],
    hdrs = ["termination_validator.h"],
    deps = [
        ":bounds_and_status_validator",
        "//ortools/base:status_macros",
        "//ortools/math_opt:result_cc_proto",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/log",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)
